#pragma once

#include "../../test.h"
#include "../Date.hpp"

namespace header
{
namespace test
{

TEST(cal_weekday)
{
    EXPECT_EQ(0, details::cal_weekday(2025, 1, 19));
    EXPECT_EQ(6, details::cal_weekday(2025, 1, 18));
    EXPECT_EQ(5, details::cal_weekday(2025, 1, 17));
    EXPECT_EQ(4, details::cal_weekday(2025, 1, 16));
    EXPECT_EQ(3, details::cal_weekday(2025, 1, 15));
    EXPECT_EQ(2, details::cal_weekday(2025, 1, 14));
    EXPECT_EQ(1, details::cal_weekday(2025, 1, 13));
    EXPECT_EQ(0, details::cal_weekday(2020, 3, 1));
    EXPECT_EQ(6, details::cal_weekday(2020, 2, 29));
    EXPECT_EQ(5, details::cal_weekday(2020, 2, 28));
    EXPECT_EQ(4, details::cal_weekday(2020, 2, 27));
    EXPECT_EQ(5, details::cal_weekday(2025, 2, 28));
    EXPECT_EQ(6, details::cal_weekday(2025, 3, 1));
    EXPECT_EQ(5, details::cal_weekday(2025, 1, 31));
}

TEST(Date)
{
    // Date date1;
    // EXPECT_EQ("2025-01-17", date1.to_string());      // current date
    Date date2(2025, 1, 1);
    EXPECT_EQ("2025-01-01", date2.to_string());
    EXPECT_EQ("2025/1/01", date2.to_string("YYYY/M/DD"));
    EXPECT_EQ("2025-01 1", date2.to_string("YYYY-MM D"));
    EXPECT_EQ("2025 1 1", date2.to_string("YYYY M D"));
    EXPECT_EQ("25-01-01", date2.to_string("YY-MM-DD"));
    EXPECT_EQ(" 25-01-01 ", date2.to_string(" YY-MM-DD "));    
    EXPECT_EQ("2025/25 01/Jan. 01/Wednesday", date2.to_string("YYYY/YY MM/MMM DD/DDDD"));

    Date date3(2025, 4, 3);
    EXPECT_EQ("25y4m3d", date3.to_string("YYyMmDd"));
    EXPECT_EQ("April-03-2025 Thursday", date3.to_string("MMMM-DD-YYYY DDDD"));

    TRY(Date(2025, 2, 29), DateTimeExcep);
    TRY(Date(2020, 2, 30), DateTimeExcep);
    TRY(Date(2025, 1, 32), DateTimeExcep);
    TRY(Date(2025, 11, 31), DateTimeExcep);

    Date date4(2025, 12, 31);
    TRY(date4.to_string("YYYYY"), DateTimeExcep);
    TRY(date4.to_string("YYYYYYY"), DateTimeExcep);
}

}   // namespace test
}   // namespace header
